package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.ExpressionsCommon;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Repository
public class ExpressionsCommonDao extends BaseDao<ExpressionsCommon> {

    public List<ExpressionsCommon> page(SplitPageBean splitPage, Map<String, Object> paraMap) {
        ArrayList<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("select * from expressions_common where 1=1");
        if(paraMap.containsKey("sex") && StringEx.isNotNull(paraMap.get("sex"))) {
            sbStr.append(" and sex=?");
            paramList.add(paraMap.get("sex"));
        }

        String sql = sbStr.toString();
        return this.queryList(sql, paramList, ExpressionsCommon.class, splitPage);
    }

    public List<ExpressionsCommon> list(Integer sex) {
        StringBuilder sbStr = new StringBuilder("select * from expressions_common where sex="+sex);

        String sql = sbStr.toString();
        return this.queryList(sql, new ArrayList<>(), ExpressionsCommon.class);
    }

    public ExpressionsCommon info(Integer id) {
        StringBuilder sbStr = new StringBuilder("select * from expressions_common where id="+id);

        String sql = sbStr.toString();
        return this.queryObj(sql, new ArrayList<>(), ExpressionsCommon.class);
    }

    public void del(Integer id) {
        StringBuilder sbStr = new StringBuilder("delete from expressions_common where id="+id);

        String sql = sbStr.toString();
        this.del(sql, new ArrayList<>());
    }

}
